package com.fyzk.activity.trend;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

import com.tyjc.lottery.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanxs11 on 2017/7/20.
 * 快三走势图
 */

public class K3TrendView extends TrendBaseView {

    private int chooseId = R.id.trend_choose_rb2;
    private int payType = 0;

    public K3TrendView(Context context) {
        super(context);
    }

    public K3TrendView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public K3TrendView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initData() {
        rowVisibleCount = 13;
        topPaddingCount = 1;
        leftPpaddingCount = 2;
        scale = 1.0f;
        rowCount = 11;
        phaseLength = 2;
        super.initData();
    }

    @Override
    boolean isShowBottom(List<Drawinfor> infors) {
        return false;
    }

    @Override
    protected void onDrawTop(Canvas canvas, Rect rect) {
        paintBg.setColor(topBg);
        super.onDrawTop(canvas, rect);
        Rect topRect = new Rect(rect.left,rect.top, rect.left, rect.top);

        paintLine.setColor(lineColor);
        paintTop.setColor(textColor666);
        switch (chooseId) {
            case R.id.trend_choose_rb1:     // 第一个选项卡——开奖
                if (payType == 0) {     // 玩法：和值
                    topRect.set(topRect.left, topRect.top, topRect.left+unitLength*5,topRect.top+unitLength);
                    drawText(canvas, paintTop, "开奖号码", topRect);
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
                    drawText(canvas, paintTop, "和值", topRect);
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
                    drawText(canvas, paintTop, "大小", topRect);
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
                    drawText(canvas, paintTop, "单双", topRect);
                } else {
                    topRect.set(topRect.left, topRect.top, (int) (topRect.left+unitLength*5.5),topRect.top+unitLength);
                    drawText(canvas, paintTop, "开奖号码", topRect);
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    topRect.set(topRect.right,topRect.top, (int) (topRect.right+unitLength*5.5),topRect.top+unitLength);
                    drawText(canvas, paintTop, "形态", topRect);
                }
                break;
            case R.id.trend_choose_rb2:     // 第二个选项卡——基本走势
                topRect.set(topRect.left, topRect.top, topRect.left+unitLength*2,topRect.top+unitLength);
                drawText(canvas, paintTop, "开奖号", topRect);
                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
                drawText(canvas, paintTop, "和值", topRect);
                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
                drawText(canvas, paintTop, "跨度", topRect);
                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                for (int i = 0; i < 6; i++) {
                    topRect.set(topRect.right, topRect.top, topRect.right+unitLength,topRect.top+unitLength);
                    String num = ""+(i+1);
                    drawText(canvas, paintTop, ""+num, topRect);
                    if (i < 5) {
                        canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    }
                }
                break;
            case R.id.trend_choose_rb3:     // 第三个选项卡——和值走势（或 形态走势  或 号码分布）
                switch (payType) {
                    case 0:     // 和值
                        for (int i = 0; i < rowCount; i++) {
                            topRect.set(topRect.right, topRect.top, topRect.right+unitLength,topRect.top+unitLength);
                            String num = ""+(i+3);
                            drawText(canvas, paintTop, ""+num, topRect);
                            if (i < rowCount-1) {
                                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                            }
                        }
                        break;
                    case 1:     // 三同号
                    case 3:     // 三不同号
                    case 5:     // 三不同胆拖
                        String[] titles = {"开奖号","三同号","三不同","二同号","二不同"};
                        for (int i = 0; i < titles.length; i++) {
                            topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*2.2),topRect.top+unitLength);
                            String num = ""+titles[i];
                            drawText(canvas, paintTop, ""+num, topRect);
                            if (i < titles.length-1) {
                                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                            }
                        }
                        break;
                    case 2:     // 二同号
                        topRect.set(topRect.right, topRect.top, topRect.right+unitLength*2,topRect.top+unitLength);
                        drawText(canvas, paintTop, "开奖号", topRect);
                        canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                        String[] titles2 = {"11","22","33","44","55","66"};
                        for (int i = 0; i < titles2.length; i++) {
                            topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
                            String num = ""+titles2[i];
                            drawText(canvas, paintTop, ""+num, topRect);
                            if (i < titles2.length-1) {
                                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                            }
                        }
                        break;
                    case 4:     // 二不同号
                    case 6:     // 二不同号胆拖
                        topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*2.5),topRect.top+unitLength);
                        drawText(canvas, paintTop, "开奖号", topRect);
                        canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                        String[] titles3 = {"12","13","14","15","16","23","24","25","26","34","35","36","45","46","56"};
                        for (int i = 0; i < titles3.length; i++) {
                            topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
                            String num = ""+titles3[i];
                            drawText(canvas, paintTop, ""+num, topRect);
                            if (i < titles3.length-1) {
                                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                            }
                        }
                        break;
                    default:
                        break;
                }
                break;
            case R.id.trend_choose_rb4:     // 第四个选项卡——冷热
                String[] titles = {"30期","50期","100期","遗漏"};
                for (int i = 0; i < titles.length; i++) {
                    topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*2.75),topRect.top+unitLength);
                    String num = ""+titles[i];
                    drawText(canvas, paintTop, ""+num, topRect);
                    if (i < titles.length-1) {
                        canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                    }
                }

                break;
            default:
                break;
        }

        paintLine.setColor(textDefault);
        canvas.drawLine(rect.left, rect.bottom-1, rect.right, rect.bottom-1, paintLine);
    }

    @Override
    protected void onDrawLeft(Canvas canvas, int left, int top) {
        if (chooseId == R.id.trend_choose_rb4) {
            paintText.setColor(textColor666);
            for (int i = 0; i < columnCount; i++) {
                rectCenter.left = left;
                rectCenter.right = rectCenter.left + leftWidth;
                rectCenter.top = top + i*unitLength;
                rectCenter.bottom = rectCenter.top + unitLength;

                if (i % 2 == 0) {
                    paintBg.setColor(bgBai);
                } else {
                    paintBg.setColor(bgHui);
                }
                canvas.drawRect(rectCenter, paintBg);
                canvas.drawLine(rectCenter.left, rectCenter.bottom, rectCenter.right, rectCenter.bottom, paintLine);
                String num = "";
                if (payType == 0) { // 和值
                    num = ""+(i+3);
                } else {
                    num = ""+(i+1);
                }
                drawText(canvas, paintText, ""+num, rectCenter);
                canvas.drawLine(rectCenter.right-1, rectCenter.top, rectCenter.right-1, rectCenter.bottom, paintLine);
            }
            if (drawHeight > unitLength*columnCount) {
                Rect bgRect = new Rect(left, top+columnCount*unitLength, leftWidth, top+drawHeight);
                paintBg.setColor(bgBai);
                canvas.drawRect(bgRect, paintBg);
                canvas.drawLine(bgRect.right-1, bgRect.top, bgRect.right-1, bgRect.bottom, paintLine);
            }
        } else {
            super.onDrawLeft(canvas, left, top);
        }
    }

    @Override
    protected void onDrawCenter(Canvas canvas, int left, int top) {
        leftAndTopTitle = "期号";
        switch (chooseId) {
            case R.id.trend_choose_rb1:
                drawCenter1(canvas, left, top);
                break;
            case R.id.trend_choose_rb2:
                drawCenter2(canvas, left, top);
                break;
            case R.id.trend_choose_rb3:
                drawCenter3(canvas, left, top);
                break;
            case R.id.trend_choose_rb4:
                drawCenter4(canvas, left, top);
                break;
            default:
                super.onDrawCenter(canvas,left,top);
                break;
        }
    }

    private void drawCenterBg(Canvas canvas, int left, int top, int i) {
        Rect bgRect = new Rect(left, top+i*unitLength, drawWidth, top+(i+1)*unitLength);
        if (i % 2 == 0) {
            paintBg.setColor(bgBai);
        } else {
            paintBg.setColor(bgHui);
        }

        canvas.drawRect(bgRect, paintBg);
        paintLine.setColor(textDefault);
        canvas.drawLine(bgRect.left, bgRect.bottom, bgRect.right, bgRect.bottom, paintLine);
    }

    private void drawPrize(Canvas canvas, int left, int top) {
        Rect topRect = new Rect(left,top,left,top);
        int count = 1;
        if (missInfors != null) {
            count = missInfors.size();
        }
        for (int i = 0; i < count; i++) {
            String windCode = "开奖号码";
            String andValue = "和值";
            String bigSmall = "大小";
            String singleDouble = "单双";
            if (missInfors != null && missInfors.size() > 0 && i < missInfors.size()) {
                List<String> infor = missInfors.get(i);
                windCode = infor.get(0);
                andValue = infor.get(1);
                bigSmall = infor.get(2);
                singleDouble = infor.get(3);
            }
            topRect.set(left,topRect.bottom,left,topRect.bottom+unitLength);
            if (missInfors != null) {
                drawCenterBg(canvas, left, top, i);
            }

            paintLine.setColor(lineColor);
            if (missInfors != null) {
                paintTop.setColor(redColor);
            } else {
                paintTop.setColor(textColor666);
            }
            topRect.set(topRect.left, topRect.top, topRect.left+unitLength*5,topRect.top+unitLength);
            drawText(canvas, paintTop, windCode, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
            if (missInfors != null) {
                paintTop.setColor(textColorMiss);
            } else {
                paintTop.setColor(textColor666);
            }
            topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
            drawText(canvas, paintTop, andValue, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
            topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
            drawText(canvas, paintTop, bigSmall, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
            topRect.set(topRect.right,topRect.top,topRect.right+unitLength*2,topRect.top+unitLength);
            drawText(canvas, paintTop, singleDouble, topRect);
        }
    }

    // 第一个选项卡——开奖
    private void drawCenter1(Canvas canvas, int left, int top) {
        if (payType == 0) {
            drawPrize(canvas, left, top);
        } else {
            Rect topRect = new Rect(left,top,left,top);
            for (int i = 0; i < columnCount; i++) {
                topRect.set(left,topRect.bottom,left,topRect.bottom+unitLength);
                drawCenterBg(canvas, left, top, i);

                paintLine.setColor(lineColor);
                String winCode = "";
                if (i < missInfors.size()) {
                    winCode = missInfors.get(i).get(0);
                }
                paintTop.setColor(redColor);
                topRect.set(topRect.left, topRect.top, (int) (topRect.left+unitLength*5.5),topRect.top+unitLength);
                drawText(canvas, paintTop, winCode, topRect);
                paintTop.setColor(textColorMiss);
                canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                topRect.set(topRect.right,topRect.top, (int) (topRect.right+unitLength*5.5),topRect.top+unitLength);
                drawText(canvas, paintTop, getNumShap(winCode), topRect);
            }
        }

    }

    private String getNumShap(String winCode) {
        String type = "";
        if (winCode.contains(" ")) {
            String[] winCodes = winCode.split(" ");

            int num1 = Integer.parseInt(winCodes[0]);
            int num2 = Integer.parseInt(winCodes[1]);
            int num3 = Integer.parseInt(winCodes[2]);

            if (num1 == num2 && num2 == num3) {
                type = "三同号";
            }else if (num1 == num2 || num1 == num3 || num2 == num3) {
                type = "二同号";
            }else if ((num1 + 1) == num2 && (num2 + 1) == num3) {
                type = "三连号";
            }else{
                type = "三不同号";
            }
        }

        return type;
    }

    // 第二个选项卡——基本走势
    private void drawCenter2(Canvas canvas, int left, int top) {
        Rect topRect = new Rect(left,top,left,top);
        List<Drawinfor> drawinfors = new ArrayList<>();
        int endIndext = 0;
        for (int i = 0; i < columnCount; i++) {

            String windCode = "- - -";
            String andValue = "-";
            String spanValue = "-";
            List<String> missValues = new ArrayList<>();
            if (missInfors != null && missInfors.size() > 0 && i < missInfors.size()) {
                if (isTJ) {
                    endIndext = missInfors.size()-4;
                } else {
                    endIndext = missInfors.size();
                }
                missValues = missInfors.get(i);
                windCode = missValues.get(0);
                andValue = missValues.get(1);
                spanValue = missValues.get(2);
            }

            drawCenterBg(canvas, left, top, i);
            topRect.set(left,topRect.bottom,left,topRect.bottom+unitLength);
            if (i == missInfors.size()-4) {
                paintLine.setColor(textDefault);
                canvas.drawLine(left, topRect.top, drawWidth, topRect.top, paintLine);
            }

            paintLine.setColor(lineColor);

            paintTop.setColor(redColor);
            topRect.set(topRect.left, topRect.top, topRect.left+unitLength*2,topRect.top+unitLength);
            drawText(canvas, paintTop, windCode, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
            paintTop.setColor(textColorMiss);
            topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
            drawText(canvas, paintTop, andValue, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
            topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*1.5),topRect.top+unitLength);
            drawText(canvas, paintTop, spanValue, topRect);
            canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);

            for (int j = 3; j < missValues.size(); j++) {
                topRect.set(topRect.right, topRect.top, topRect.right+unitLength,topRect.top+unitLength);
                String num = ""+(j-2);
                if (missValues.size() > 0 && j < missValues.size()) {
                    if (i >= endIndext) {
                        num = ""+missValues.get(j);
                    } else {
                        if (missValues.get(j).equals("0")) {
                            Drawinfor drawinfor = new Drawinfor();
                            num = ""+(j-2);
                            drawinfor.findCount = appearNumber(windCode, num);
                            drawinfor.text = num;
                            drawinfor.rect = new Rect(topRect.left, topRect.top, topRect.right, topRect.bottom);
                            drawinfor.shapType = 1;
                            drawinfor.textColor = Color.WHITE;
                            drawinfor.shapColor = redColor;
                            drawinfors.add(drawinfor);
                        }
                        if (isYL) {
                            num = ""+missValues.get(j);
                        } else {
                            num = "";
                        }
                    }

                    if (i == missInfors.size()-4) {
                        paintTop.setColor(color_showCount);
                    } else if (i == missInfors.size() - 3) {
                        paintTop.setColor(color_average);
                    } else if (i == missInfors.size() - 2) {
                        paintTop.setColor(color_maxMiss);
                    } else if (i == missInfors.size() - 1) {
                        paintTop.setColor(color_maxLian);
                    } else {
                        paintTop.setColor(textColorMiss);
                    }
                }
                drawText(canvas, paintTop, ""+num, topRect);
                if (j < missValues.size()) {
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                }
            }
            if (i == columnCount - 1) {
                drawShap(canvas, drawinfors, false);
            }
        }
    }

    // 第三个选项卡——和值走势（或 形态走势  或 号码分布）
    private void drawCenter3(Canvas canvas, int left, int top) {
        Rect topRect = new Rect(left,top,left,top);
        List<Drawinfor> drawinfors = new ArrayList<>();
        float unitCount = 1;
        int endIndext = 0;
        String[] numStrs = {"开奖号","三同号","三不同","二同号","二不同"};
        String[] numStrs2 = {"开奖号","11","22","33","44","55","66"};
        String[] numStrs3 = {"开奖号","12","13","14","15","16","23","24","25","26","34","35","36","45","46","56"};
        for (int i = 0; i < columnCount; i++) {
            List<String> missValues = new ArrayList<>();
            if (missInfors.size() > 0) {
                missValues = missInfors.get(i);
                if (isTJ) {
                    endIndext = missInfors.size()-4;
                } else {
                    endIndext = missInfors.size();
                }
            }

            drawCenterBg(canvas, left, top, i);
            topRect.set(left,topRect.bottom,left,topRect.bottom+unitLength);

            if (i == missInfors.size()-4) {
                paintLine.setColor(textDefault);
                canvas.drawLine(left, topRect.top, drawWidth, topRect.top, paintLine);
            }

            paintLine.setColor(lineColor);


            for (int j = 0; j < rowCount && j < missValues.size(); j++) {
                String num = ""+(j+3);
                switch (payType) {
                    case 1:     // 三同号
                    case 3:     // 三不同号
                    case 5:     // 三不同胆拖
                        unitCount = 2.2f;
                        break;
                    case 2:     // 二同号
                        if (j == 0) {
                            unitCount = 2;
                        } else {
                            unitCount = 1.5f;
                        }
                        break;
                    case 4:     // 二不同号
                    case 6:     // 二不同号胆拖
                        if (j == 0) {
                            unitCount = 2.5f;
                        } else {
                            unitCount = 1.5f;
                        }
                        break;
                    default:
                        break;
                }
                topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*unitCount),topRect.top+unitLength);
                if (missValues.size() > 0) {
                    if (i >= endIndext) {
                        num = ""+missValues.get(j);
                    } else {
                        if (missValues.get(j).equals("0")) {
                            Drawinfor drawinfor = new Drawinfor();
                            switch (payType) {
                                case 1:     // 三同号
                                case 3:     // 三不同号
                                case 5:     // 三不同胆拖
                                    if (j < numStrs.length)
                                    num = numStrs[j];
                                    break;
                                case 2:     // 二同号
                                    if (j < numStrs2.length)
                                    num = numStrs2[j];
                                    break;
                                case 4:     // 二不同号
                                case 6:     // 二不同号胆拖
                                    if (j < numStrs3.length)
                                    num = numStrs3[j];
                                    break;
                                default:
                                    num = ""+(j+3);
                                    break;
                            }
                            drawinfor.text = num;
                            drawinfor.rect = new Rect(topRect.left, topRect.top, topRect.right, topRect.bottom);
                            drawinfor.shapType = 1;
                            drawinfor.textColor = Color.WHITE;
                            drawinfor.shapColor = redColor;
                            drawinfors.add(drawinfor);
                        }
                        if (isYL) {
                            num = ""+missValues.get(j);
                        } else {
                            if (j == 0 && payType != 0) {
                                num = ""+missValues.get(j);
                            } else {
                                num = "";
                            }
                        }
                    }

                }
                if (j == 0 && payType != 0) {
                    paintTop.setColor(redColor);
                } else {
                    if (i == missInfors.size()-4) {
                        paintTop.setColor(color_showCount);
                    } else if (i == missInfors.size() - 3) {
                        paintTop.setColor(color_average);
                    } else if (i == missInfors.size() - 2) {
                        paintTop.setColor(color_maxMiss);
                    } else if (i == missInfors.size() - 1) {
                        paintTop.setColor(color_maxLian);
                    } else {
                        paintTop.setColor(textColorMiss);
                    }
                }
                drawText(canvas, paintTop, ""+num, topRect);
                if (j < rowCount-1) {
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                }
            }
            if (i == columnCount - 1) {
                drawShap(canvas, drawinfors, payType == 0 ? isZX : false);
            }
        }
    }

    // 第四个选项卡——冷热
    private void drawCenter4(Canvas canvas, int left, int top) {
        leftAndTopTitle = "号码";
        Rect topRect = new Rect(left,top,left,top);
        for (int i = 0; i < columnCount; i++) {
            List<String> missValues = new ArrayList<>();
            if (missInfors.size() > 0) {
                missValues = missInfors.get(i);
            }
            drawCenterBg(canvas, left, top, i);

            topRect.set(left,topRect.bottom,left,topRect.bottom+unitLength);
            paintLine.setColor(lineColor);

            int rCount = 4;
            for (int j = 0; j < rCount; j++) {
                String num = "";
                if (missValues.size() > 0) {
                    if (j < missValues.size()) {
                        num = ""+missValues.get(j);
                        if (num.equals(trendBean.maxMiss[j])) {
                            paintTop.setColor(redColor);
                        } else {
                            paintTop.setColor(textColorMiss);
                        }
                    }
                }
                topRect.set(topRect.right, topRect.top, (int) (topRect.right+unitLength*2.75),topRect.top+unitLength);
                drawText(canvas, paintTop, ""+num, topRect);
                if (j < 3) {
                    canvas.drawLine(topRect.right-1, topRect.top, topRect.right-1, topRect.bottom, paintLine);
                }
            }
        }
        if (drawHeight > unitLength*columnCount) {
            Rect bgRect = new Rect(left, top+columnCount*unitLength, drawWidth, top+drawHeight);
            paintBg.setColor(bgBai);
            canvas.drawRect(bgRect, paintBg);
        }

    }

    @Override
    public void onChooseClick(int id) {
        super.onChooseClick(id);
        chooseId = id;
        setRowCount(11);
        switch (id) {
            case R.id.trend_choose_rb1:
                setColumnCount(50, false);
                break;
            case R.id.trend_choose_rb2:
                setColumnCount(50, false);
                break;
            case R.id.trend_choose_rb3:
                switch (payType) {
                    case 0:
                        setRowCount(16);
                        break;
                    case 4:
                    case 6:
                        setRowCount(25);
                        break;
                    default:
                        setRowCount(11);
                        break;
                }
                setColumnCount(50, false);
                break;
            case R.id.trend_choose_rb4:
                switch (payType) {
                    case 0:     // 和值
                        setColumnCount(16, true);
                        break;
                    default:
                        setColumnCount(6, true);
                        break;
                }
                break;
            default:
                break;
        }
        setMissTitle(chooseId, payType);
    }

    @Override
    public void onChangePayType(int id) {
        super.onChangePayType(id);
        payType = id;
        setMissTitle(chooseId, payType);
    }

    private void setMissTitle(int chooseId, int payType) {
        hcTitle = "hc";
        missTitle = "miss";
        setMissInfors(payType, chooseId);
    }

    private int appearNumber(String srcText, String findText) {
        int count = 0;
        int index = 0;
        while ((index = srcText.indexOf(findText, index)) != -1) {
            index = index + findText.length();
            count++;
        }
        return count;
    }

    @Override
    protected void setColumn(int paytype, int chooseId) {
        switch (chooseId) {
            case R.id.trend_choose_rb2:
                if (isTJ) {
                    columnCount = missInfors.size();
                } else {
                    columnCount = missInfors.size() - 4;
                }
                break;
            case R.id.trend_choose_rb3:
                if (isTJ) {
                    columnCount = missInfors.size();
                } else {
                    columnCount = missInfors.size() - 4;
                }
                break;
            default:
                columnCount = missInfors.size();
                break;
        }
    }
}
